{template '_header'}
 
<div class="page-heading">
    <span class="pull-right">
           {if 'perm.user.add' && $_W['accounttotal']>$total}
                   <a class='btn btn-primary btn-sm' href="{php echo merchUrl('perm/user/add')}"><i class="fa fa-plus"></i> 添加新操作员</a>
           {/if}
    </span>
    <h2>操作员管理 <small>当前添加[ {$total} ]个 还可以添加[ {php echo $_W['accounttotal']-$total <=0 ? 0 : $_W['accounttotal']-$total} ]</small></h2>
</div>


           <form action="./merchant.php" method="get" class="form-horizontal" user="form">
                <input type="hidden" name="c" value="site" />
                <input type="hidden" name="a" value="entry" />
                <input type="hidden" name="m" value="ewei_shopv2" />
                <input type="hidden" name="do" value="web" />
                <input type="hidden" name="r"  value="perm.user" />
<div class="page-toolbar row m-b-sm m-t-sm">
                            <div class="col-sm-4">
				 
			   <div class="input-group-btn">
			        <button class="btn btn-default btn-sm"  type="button" data-toggle='refresh'><i class='fa fa-refresh'></i></button>
				  {ifp 'perm.user.edit'}
			                        <button class="btn btn-default btn-sm" type="button" data-toggle='batch' data-href="{php echo merchUrl('perm/user/status',array('status'=>1))}"><i class='fa fa-circle'></i> 启用</button>
				   <button class="btn btn-default btn-sm" type="button" data-toggle='batch'  data-href="{php echo merchUrl('perm/user/status',array('status'=>0))}"><i class='fa fa-circle-o'></i> 禁用</button>
				   {/if}
				{ifp 'perm.user.delete'}	
			        <button class="btn btn-default btn-sm" type="button" data-toggle='batch-remove' data-confirm="确认要删除?" data-href="{php echo merchUrl('perm/user/delete')}"><i class='fa fa-trash'></i> 删除</button>
				{/if}
	 
			   </div> 
                               </div>	
	  
			 
                            <div class="col-sm-6 pull-right">
		  <select name="roleid" class='form-control input-sm select-sm'>
                            <option value="" {if $_GPC['roleid']==''} selected{/if}>角色</option>
                            <option value="0" {if $_GPC['roleid']=='0'} selected{/if}>无角色</option>
                            {loop $roles $role}
                            <option value="{$role['id']}" {if $_GPC['roleid']== $role['id']} selected{/if}>{$role['rolename']}</option>
                            {/loop}
                            
                        </select>  
				<select name="status" class='form-control input-sm select-sm'>
					<option value="" {if $_GPC['status'] == ''} selected{/if}>状态</option>
					 <option value="1" {if $_GPC['status']== '1'} selected{/if}>启用</option>
					 <option value="0" {if $_GPC['status'] == '0'} selected{/if}>禁用</option>
				</select>	
				<div class="input-group">				 
                                        <input type="text" class="input-sm form-control" name='keyword' value="{$_GPC['keyword']}" placeholder="请输入关键词"> <span class="input-group-btn">
						
                                     <button class="btn btn-sm btn-primary" type="submit"> 搜索</button> </span>
                                </div>
								
                            </div>
</div>
  </form>
 {if count($list)>0}
 

            <table class="table table-hover table-responsive">
                <thead>
                    <tr>
                         <th style="width:25px;"><input type='checkbox' /></th>
                        <th style='width:200px'>登录ID</th>
                        <th style='width:100px'>角色</th>
                        <th style='width:100px'>姓名</th>
                        <th style='width:100px'>手机</th>
                        <th style='width:80px'>状态</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    {loop $list $row}
                    <tr>
                         <td><input type='checkbox'   value="{$row['id']}"/></td>
                        <td>{$row['username']}</td>
                        <td>{php echo !empty($row['rolename'])?$row['rolename']:'无'}</td>
                        <td>{$row['realname']}</td>
                        <td>{$row['mobile']}</td>
                        <td>
                           <span class='label {if $row['status']==1}label-success{else}label-default{/if}' 
										  {ifp 'shop.adv.edit'}
										  data-toggle='ajaxSwitch' 
										  data-switch-value='{$row['status']}'
										  data-switch-value0='0|禁用|label label-default|{php echo merchUrl('perm/user/status',array('status'=>1,'id'=>$row['id']))}'  
										  data-switch-value1='1|启用|label label-success|{php echo merchUrl('perm/user/status',array('status'=>0,'id'=>$row['id']))}'  
										  {/if}
										>
										  {if $row['status']==1}启用{else}禁用{/if}</span>
                        </td>
                        <td>
                            {ifp 'perm.user.view|perm.user.edit'}<a class='btn btn-default btn-sm' href="{php echo merchUrl('perm/user/edit', array('id' => $row['id']))}"><i class="fa fa-edit"></i>  {ifp 'perm.role.edit'}编辑{else}查看{/if}</a>{/if}
                            {ifp 'perm.user.delete'}<a class='btn btn-default btn-sm' data-toggle='ajaxRemove'  href="{php echo merchUrl('perm/user/delete', array('id' => $row['id']))}" data-confirm="确认删除此操作员吗？"><i class="fa fa-trash"></i> 删除</a>{/if}
                        
                        </td>
                    </tr>
                    {/loop}
                 
                </tbody>
            </table>
            {$pager}
          {else}
<div class='panel panel-default'>
	<div class='panel-body' style='text-align: center;padding:30px;'>
		 暂时没有任何操作员!
	</div>
</div>

</form>



{/if}
<script language='javascript'>
 
                function search_users() {
		$("#module-menus1").html("正在搜索....")
		$.get('{php echo merchUrl('perm/user',array('op'=>'query'));}', {
			keyword: $.trim($('#search-kwd1').val())
		}, function(dat){
			$('#module-menus1').html(dat);
		});
	}
	function select_user(o) {
		$("#userid").val(o.id);
		$("#user").val( o.username );
                                var perms = o.perms.split(',');
                                $(':checkbox')
                                $(':checkbox').removeAttr('disabled').removeAttr('checked').each(function(){
                                    
                                    var _this = $(this);
                                    var perm = '';
                                    if( _this.data('group') ){
                                        perm+=_this.data('group');
                                    }
                                    if( _this.data('child') ){
                                        perm+="." +_this.data('child');
                                    }
                                    if( _this.data('op') ){
                                        perm+="." +_this.data('op');
                                    }
                                    if( $.arrayIndexOf(perms,perm)!=-1){
                                        $(this).attr('disabled',true).get(0).checked =true;
                                    }
                                     
                                });
		$(".close").click();
	}
    </script>
{template '_footer'}
 